package com.ztc.util.enums;

/**
 * 订单状态.
 */
public enum OrderStatus {

    ORDER_CANCEL(-1,"订单取消"),
    ORDERED_WITTING(0,"已下单"),
    ORDER_PAID(1,"已付款"),
    ORDER_SUCCESS(2,"订票成功"),
    ORDER_OVER(3,"订单完成"),
    ORDER_REFUNDING(4,"退款中"),
    ORDER_REFUND_SUCCESS(5,"退款成功"),
    ORDER_REFUND_FAIL(6,"退款失败");

    private int code;
    private String status;

    public int getCode() {
        return code;
    }
    public String getStatus() {
        return status;
    }

    private OrderStatus(int code, String status) {
        this.code = code;
        this.status = status;
    }
    //解析code返回字符串实际状态
    public static String getStatusInfos(Integer code){
        for (OrderStatus orderStatus : values()) {
            if(orderStatus.getCode()==code){
                return orderStatus.getStatus();
            }
        }
        return null;
    }
    //解析获取字符串实际code
    public static Integer getStatusCode(String infos){
        for (OrderStatus orderStatus : values()) {
            if(orderStatus.getStatus().equals(infos)){
                return orderStatus.getCode();
            }
        }
        return -1;
    }
}
